{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "6d60aab6",
   "metadata": {},
   "source": [
    "### Prerequisites\n",
    "Make sure you have installed the following two packages\n",
    "```\n",
    "llama-index-agent-openai\n",
    "llama-index-tools-elevenlabs\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4cdf841d-bc87-4138-96d6-f8b6b173ddd8",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Setup OpenAI Agent\n",
    "import os\n",
    "\n",
    "os.environ[\"OPENAI_API_KEY\"] = \"your-key\"\n",
    "from llama_index.core.agent.workflow import FunctionAgent\n",
    "from llama_index.llms.openai import OpenAI"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6358bd48-627c-47d6-9761-376877195950",
   "metadata": {},
   "outputs": [],
   "source": [
    "from llama_index.tools.elevenlabs import ElevenLabsToolSpec\n",
    "\n",
    "speech_tool = ElevenLabsToolSpec(api_key=\"your-key\")\n",
    "\n",
    "agent = FunctionAgent(\n",
    "    tools=[*speech_tool.to_tool_list()],\n",
    "    llm=OpenAI(model=\"gpt-4.1\"),\n",
    ")\n",
    "print(\n",
    "    await agent.run(\n",
    "        'Get the list of available voices, select ONLY the first voice, and use it to create speech from the text \"Hello world!\" saving to \"speech.wav\"'\n",
    "    )\n",
    ")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "llama-index-UJ2SQPf2-py3.13",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
